Global Enumerations

Hi Everyone,

I am looking to set a global list for an enumerated type I created. This Attribute is used in a lot of different modules and don't want to have to go through and change all the locations of the attribute if something needs to be added to the type. Is there a way to do this?? Can you set up a list in one module, import the attribute from that module, then if you added another enumeration, it's updated everywhere that type is used??

Thanks
SystemAdmin - Mon Feb 23 12:36:57 EST 2009

Re: Global Enumerations
llandale - Tue Feb 24 16:34:27 EST 2009

I'm sure the GUI has no solution, but you can write DXL to do it. For enumerations it would get pretty sticky.

There is an undocumented perm AttrType modify(AttrType, string, string], int[, int], int[, string&) which has one more 'int[]' parameter than in the manual, that lets you map new enumerations to the old.

If the old Enumerations were A/B/C and the new are A/C/B/D, you might intend ...

[] ... to swap the display order of B and C, and add D.

[] ... to rename all existing C to B and rename all existing B to C and then add D; the new mapping function above will let you do that. Perhaps A/X/Y/D would be easier to understand.

[] ... move C, map existing B to D, create new B. Other possibilities exist.

Also, when you map the object's haven't actually changed values yet and will generally display the OLD values; which means pretty much you need to plow through all the objects and do this: obj.NameAttr = obj.NameAttr, in order to update the display.

So no, you cannot just modify the enumerations and push it out, you'd have to mindfully decide what you intend and customize the DXL to do it for you.

Good luck.

  • Louie

Re: Global Enumerations
SystemAdmin - Tue Feb 24 16:48:58 EST 2009

Hi louie,
Thank you very much for your response.

I don't know a lot about DXL or programming in doors. I have only done a few little things here and there. I am just surprised there isn't a String that the Enumeration values are assigned to. So then I figured if there was, couldn't you simply change the Enumerations values in one module and then run a DXL script that would look for the old variable and replace it with the old.

for example, Values = A,B,C which is assigned to String Enumeration
Then you set Values = A,B,C,D which will be assigned to String Enumeration.

Then search for Enumeration (old) and replace it with Enumeration (new).

This way when the Type looks for the variable to create the Enumerated list to choose from it has the new value in it.

Like I said I don't know DXL or even how Enumerations are programmed, or if you can do a search routine in DXL.

Jamie

Re: Global Enumerations
SystemAdmin - Tue Feb 24 16:52:58 EST 2009

Hi Louie,

I"m sorry I just reread your post, and you might of solved my problem I just didn't understand it.

I have to look up the command AttrType modify that you are referring to. I just haven't worked with it before and don't fully understand the syntax that you use to program it.

Thanks again

Jamie

Re: Global Enumerations; type 101
llandale - Wed Feb 25 14:04:04 EST 2009

SystemAdmin - Tue Feb 24 16:52:58 EST 2009
Hi Louie,

I"m sorry I just reread your post, and you might of solved my problem I just didn't understand it.

I have to look up the command AttrType modify that you are referring to. I just haven't worked with it before and don't fully understand the syntax that you use to program it.

Thanks again

Jamie

Ok, let me step back a bit.

All attributes definitions must have an attribute 'type' which restricts ..err.. clarifies what kinds of information can be in that attribute. Attr 'Count' is of type 'Integer'; attr '%Complete' is of type 'Real' (with boundaries 0.0 - 100.0); 'Name' is of type 'string' and 'Object Text' is type 'Text'. In the case of '%Complete' you would create a type called 'Percent' of base type 'Real' with min and max values of 0.0 and 100.0, and THEN create Attr Def '%Complete' that uses type 'Percent'.

An 'enumerated' attribute is one that has a specific list of legal values, or of course null. You cannot assign a value to an object for that attribute that's not in the list. A 'single' enumerated attribute allows you to pick zero or one of the values; e.g. 'Priority' can be 'High' or 'Medium' but not both. A 'multi' enumerated attribute allows you to pick zero or more of the values, e.g. 'ChoresToDo' can be both 'MakeBed' and 'CleanRoom'.

For enumerated attributes, the legal values are defined in the 'Type' and you must create your own 'Type' before creating the actual attribute. For example, type 'Boolean' is really an enumerated type of legal values 'False' or 'True' allowing you to create attr definition 'Verified'. You can create a single enumerated Type perhaps 'Importance' with enumerations 'Critical', 'High', 'Medium', 'Low', and 'Trivial', and then create several Attr Defs that use them, perhaps 'Implementation Priority' and 'Customer Demands', assigning values for each object. However, most of the time you create an enumerated type for use by a single enumerated definition. They can have the exact same name, perhaps definition 'Available Upgrades' can be based on type 'Available Upgrades'.

You cannot change the type of an attribute; if 'Name' is type 'String' you cannot change it to type 'Text'. The awkward way to do that is this for each object copy 'Name' to 'Temp' Rename 'Temp' to 'Name'.

Back to the thread. You CAN change the enumerated list of an enumerated type; lets do that with the GUI.

If you change the ORDER in which the values are displayed, then for multi-enumerated the order displays the new order for each object, if you update the object. If you change enumerated A-B-C to C-A-B and an object starts with values A and C, the object will still say A C even after you re-order it; you can force redisplay (and reordering) in DXL with <obj.NameAttr = obj.NameAttr> for all objects in the entire module; in this case C A.

If you change the spelling of an enumerated, perhaps 'C' to 'CC', then all objects (oddly) immediately update to the new value.

If you delete an enumerated, all objects lose that value immediately.

Not sure what happens if you have rights to modify the Type like this but don't have rights to modify the Attr Values.

Now lets modify a Type with DXL.

The 'modify' command lets you define the new order, and the undocumented version including the mapping[] array lets you associate old values with new, where -1 means no association. IIRC if mapping[0] has the value 2 it means that the new enumerated value in the other arrays in position 0 maps directly to the older enumerations at position 2. In that case, it lets you move 2 to 0 (if spelled the same) and also lets you change the spelling of the old 2 into the new 0.

I don't think its reasonable ..err.. possible to expect a generic DXL script to read the old list of enumerations (from an actual module), read the new list (from the template), and be able to figure out how to populate the arrays, including the mapping, needed for the 'modify' command. If you renamed 2 and moved it to position 0, how on earth would the script know that? e.g. A B C is old and CC A B is new, that could be 3 straight renames, that could be renaming C to CC and moving it to the top (the 2-to-0 example above), and it could also be deleting C and inserting a new CC at the top.

No, I'm sure your rename enumerations script will need to be tailored to change the enumerations of each specific attribute. Perhaps you can write one that reads an CSV file with the info you want, but you'd still need a CSV file for each and every rename you attempt.

  • Louie

Re: Global Enumerations; type 101
SystemAdmin - Wed Feb 25 16:36:41 EST 2009

llandale - Wed Feb 25 14:04:04 EST 2009
Ok, let me step back a bit.

All attributes definitions must have an attribute 'type' which restricts ..err.. clarifies what kinds of information can be in that attribute. Attr 'Count' is of type 'Integer'; attr '%Complete' is of type 'Real' (with boundaries 0.0 - 100.0); 'Name' is of type 'string' and 'Object Text' is type 'Text'. In the case of '%Complete' you would create a type called 'Percent' of base type 'Real' with min and max values of 0.0 and 100.0, and THEN create Attr Def '%Complete' that uses type 'Percent'.

An 'enumerated' attribute is one that has a specific list of legal values, or of course null. You cannot assign a value to an object for that attribute that's not in the list. A 'single' enumerated attribute allows you to pick zero or one of the values; e.g. 'Priority' can be 'High' or 'Medium' but not both. A 'multi' enumerated attribute allows you to pick zero or more of the values, e.g. 'ChoresToDo' can be both 'MakeBed' and 'CleanRoom'.

For enumerated attributes, the legal values are defined in the 'Type' and you must create your own 'Type' before creating the actual attribute. For example, type 'Boolean' is really an enumerated type of legal values 'False' or 'True' allowing you to create attr definition 'Verified'. You can create a single enumerated Type perhaps 'Importance' with enumerations 'Critical', 'High', 'Medium', 'Low', and 'Trivial', and then create several Attr Defs that use them, perhaps 'Implementation Priority' and 'Customer Demands', assigning values for each object. However, most of the time you create an enumerated type for use by a single enumerated definition. They can have the exact same name, perhaps definition 'Available Upgrades' can be based on type 'Available Upgrades'.

You cannot change the type of an attribute; if 'Name' is type 'String' you cannot change it to type 'Text'. The awkward way to do that is this for each object copy 'Name' to 'Temp' Rename 'Temp' to 'Name'.

Back to the thread. You CAN change the enumerated list of an enumerated type; lets do that with the GUI.

If you change the ORDER in which the values are displayed, then for multi-enumerated the order displays the new order for each object, if you update the object. If you change enumerated A-B-C to C-A-B and an object starts with values A and C, the object will still say A C even after you re-order it; you can force redisplay (and reordering) in DXL with <obj.NameAttr = obj.NameAttr> for all objects in the entire module; in this case C A.

If you change the spelling of an enumerated, perhaps 'C' to 'CC', then all objects (oddly) immediately update to the new value.

If you delete an enumerated, all objects lose that value immediately.

Not sure what happens if you have rights to modify the Type like this but don't have rights to modify the Attr Values.

Now lets modify a Type with DXL.

The 'modify' command lets you define the new order, and the undocumented version including the mapping[] array lets you associate old values with new, where -1 means no association. IIRC if mapping[0] has the value 2 it means that the new enumerated value in the other arrays in position 0 maps directly to the older enumerations at position 2. In that case, it lets you move 2 to 0 (if spelled the same) and also lets you change the spelling of the old 2 into the new 0.

I don't think its reasonable ..err.. possible to expect a generic DXL script to read the old list of enumerations (from an actual module), read the new list (from the template), and be able to figure out how to populate the arrays, including the mapping, needed for the 'modify' command. If you renamed 2 and moved it to position 0, how on earth would the script know that? e.g. A B C is old and CC A B is new, that could be 3 straight renames, that could be renaming C to CC and moving it to the top (the 2-to-0 example above), and it could also be deleting C and inserting a new CC at the top.

No, I'm sure your rename enumerations script will need to be tailored to change the enumerations of each specific attribute. Perhaps you can write one that reads an CSV file with the info you want, but you'd still need a CSV file for each and every rename you attempt.

  • Louie

Louie wrote "Not sure what happens if you have rights to modify the Type like this but don't have rights to modify the Attr Values."

Yep - this one has caused me grief in the past - the scenario you mention above will allow a user to fully edit the Type but will not allow the user to edit the Attribute value of each module object. Have seen users skirt around the access restrictions on Attribute values by editing the Type. Because Attr Types support a one to many mapping relationship to Attr Defs, you can see the complexity and conflicts of trying to flow down access rights from Defs to Types. It's a pain having to second guess all of the ways that users can subvert due process, I just have to make sure that access permissions to all custom Attr Types in module templates only allow members of an Admin group to modify them.


Paul Miller
EuroCyber
Melbourne, Australia

Re: Global Enumerations
ePiallat - Thu Feb 26 05:15:35 EST 2009

llandale - Tue Feb 24 16:34:27 EST 2009
I'm sure the GUI has no solution, but you can write DXL to do it. For enumerations it would get pretty sticky.

There is an undocumented perm AttrType modify(AttrType, string, string], int[, int], int[, string&) which has one more 'int[]' parameter than in the manual, that lets you map new enumerations to the old.

If the old Enumerations were A/B/C and the new are A/C/B/D, you might intend ...

[] ... to swap the display order of B and C, and add D.

[] ... to rename all existing C to B and rename all existing B to C and then add D; the new mapping function above will let you do that. Perhaps A/X/Y/D would be easier to understand.

[] ... move C, map existing B to D, create new B. Other possibilities exist.

Also, when you map the object's haven't actually changed values yet and will generally display the OLD values; which means pretty much you need to plow through all the objects and do this: obj.NameAttr = obj.NameAttr, in order to update the display.

So no, you cannot just modify the enumerations and push it out, you'd have to mindfully decide what you intend and customize the DXL to do it for you.

Good luck.

  • Louie

llandale wrote:
> There is an undocumented perm AttrType modify(AttrType, string, string[], int[], int[], int[], string&) which has one more 'int[]' parameter than in the manual, that lets you map new enumerations to the old.

Sorry that it has nothing todo with the core subject here, but I told the same during a DXL training and was corrected by a trainee:
This perm is documented! (At least in DOORS 8 manual even if the DOORS 5 manual didn't)

Documented "AttrType modify" prototypes are:
AttrType modify(AttrType type, string newName, string &errmess)
AttrType modify(AttrType type, AttrBaseType new, string &errmess)
AttrType modify(AttrType type, string newName, string codes[ ], int values[ ], int colors[ ], string &errmess)
AttrType modify(AttrType type, string newName, string codes[ ], int values[ ], int colors[ ], int arrMaps[ ], string &errmess)

– Éric

Re: Global Enumerations
SystemAdmin - Thu Feb 26 07:50:45 EST 2009

Hi Louie,

Your last option you talk about with having it read a CSV file sounds like a great solution. I don't mind having a bunch of CSV files every time I make a change to the Type list as long as I can have every time that type is used refer to a Single CSV file. The problem for me is when if I have to add a name to the type list, there is over a hundred places (spread over multiple modules and projects) where I would have to go into the type and change it. I am just trying to cut down on the maintance of the over all project.

Thanks for being patient with me I hope I'm not frustrating you or missing the point.

Thanks again,
Jamie